package com.wenhui.schoolyardinfo.firstpage.bean;

import android.text.TextUtils;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * author    : Urasaki
 * e-mail    : 1164688204@qq.com
 * date      : 2019/6/20 13:54
 * introduce :
 */

public class SchoolChoiceBean {

    private String name;
    private String pinyin;
    private boolean isChecked;

    /***
     * 获取悬浮栏文本，（#、定位、热门 需要特殊处理）
     * @return
     */
    public String getSection() {
        if (pinyin != null && !"".equals(pinyin)) {
            String c = pinyin.substring(0, 1);
            Pattern p = Pattern.compile("[a-zA-Z]");
            Matcher m = p.matcher(c);
            if (m.matches()) {
                return c.toUpperCase();
            } else if ("历".equals(c) || "热".equals(c)) {
                //在添加历史和热门数据时设置的section就是‘历’、’热‘开头
                return pinyin;
            } else {
                return "#";
            }
        } else {
            return "#";
        }
    }

    public SchoolChoiceBean() {
    }

    public SchoolChoiceBean(String name, String pinyin, boolean isChecked) {
        this.name = name;
        this.pinyin = pinyin;
        this.isChecked = isChecked;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPinyin() {
        return pinyin;
    }

    public void setPinyin(String pinyin) {
        this.pinyin = pinyin;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    @Override
    public String toString() {
        return "SchoolChoiceBean{" +
                "name='" + name + '\'' +
                ", pinyin='" + pinyin + '\'' +
                ", isChecked=" + isChecked +
                '}';
    }
}
